package com.jimmy.tx.controller;

import com.jimmy.tx.service.RoleService;
import com.jimmy.tx.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @version 1.0
 * @ ClassName App
 * <p> TODO
 * @ author JIMMY
 * @ Date 2020/11/5 0005 下午 9:26
 */
public class App {
    public static void main(String[] args) {
//      test1();
//        test2();
        test3();
    }
    public static void test1(){
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService) ctx.getBean("userService");
        userService.transfer("jerry","tom",100.0);
//        userService.transferTrancation("jerry","tom",100.0); //测试编程式事务
    }
    //测试声明式事务
    public static void test2(){
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext2.xml");
        RoleService roleService = (RoleService) ctx.getBean("roleService");
        roleService.transfer("jerry","tom",100.0);
    }
    //测试事务的传播行为
    public static void test3(){
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext3.xml");
        RoleService roleService = (RoleService) ctx.getBean("roleService");
        roleService.transfer("jerry","tom",100.0);
    }
}
